package cn.openea.perpartner.meily.web.service.impl;

import cn.openea.perpartner.common.core.exception.ServiceException;
import cn.openea.perpartner.common.core.utils.StringUtils;
import cn.openea.perpartner.meily.web.entity.LogisticsInfo;
import cn.openea.perpartner.meily.web.mapper.LogisticsInfoMapper;
import cn.openea.perpartner.meily.web.service.ILogisticsInfoService;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * 物流service
 */
@Service("logisticsInfoService")
public class LogisticsInfoServiceImpl extends ServiceImpl<LogisticsInfoMapper, LogisticsInfo> implements ILogisticsInfoService {

    @Override
    public void updateBusinessStatus(String id, Short businessStatus) {
        if (StringUtils.isBlank(id) || businessStatus == null){
            throw new ServiceException("数据异常");
        }
        LambdaUpdateWrapper<LogisticsInfo> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(LogisticsInfo::getId,id);
        updateWrapper.set(LogisticsInfo::getBusinessStatus,businessStatus);
        update(updateWrapper);
    }

    @Override
    public void businessDelayedReceipt(String id, int days) {
        if (StringUtils.isBlank(id)){
            throw new ServiceException("数据异常");
        }
        LambdaUpdateWrapper<LogisticsInfo> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(LogisticsInfo::getId,id);
        updateWrapper.set(LogisticsInfo::getDelayedReceiptDays,days);
        update(updateWrapper);
    }
}